package com.jcl.recruit.elasticsearch.recruit.service;

import com.jcl.recruit.elasticsearch.resume.logic.ResumeDownloadLogic;
import com.jcl.recruit.elasticsearch.resume.model.ResumeExternalMsg;
import com.jcl.recruit.elasticsearch.thread.ResumeDownloadTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @ClassName RecruitElasticService
 * @Author yyliu
 * @Date 2018/12/25 17:29
 * @Version 1.0
 **/
@Service
public class RecruitElasticService {

    @Autowired
    private ResumeDownloadLogic resumeDownloadLogic;


    public ResumeExternalMsg download(String tenantId, String corpCode, Integer resumeId) {

        ResumeExternalMsg resumeExternalMsg = resumeDownloadLogic.getExternalMsg(resumeId);
        if (null == resumeExternalMsg) {
            // 没有外部关联信息
            return null;
        }
        Map<String, Object> data = resumeDownloadLogic.createDownloadMap(tenantId, corpCode, resumeExternalMsg);

        ResumeDownloadTask.start(data);

        return resumeExternalMsg;
    }

}
